//
//  BaseView.m
//  callmed
//
//  Created by x x on 2017/9/21.
//  Copyright © 2017年 xx. All rights reserved.
//

#import "BaseView.h"

@interface BaseView ()
{
    id hideTarget;
    SEL hideSelector;
    id refreshCenterTarget;
    SEL refreshCenterSelector;
    id addKeyboardTarget;
    SEL addKeyboardSelector;
}

@end

@implementation BaseView

+ (instancetype)createWithView
{
    BaseView *tmp = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil] lastObject];
    
    [tmp initWithView];
    
    return tmp;
}

- (void)initWithView
{
    
}

- (void)addHideTarget:(id)target action:(SEL)action
{
    hideTarget = target;
    hideSelector = action;
}

- (void)hideView
{
    SuppressPerformSelectorLeakWarning([hideTarget performSelector:hideSelector];);
}

- (void)addCenterTarget:(id)target action:(SEL)action
{
    refreshCenterTarget = target;
    refreshCenterSelector = action;
}

- (void)updateView
{
    SuppressPerformSelectorLeakWarning([refreshCenterTarget performSelector:refreshCenterSelector];);
}

- (void)addKeyboardTarget:(id)target action:(SEL)action
{
    addKeyboardTarget = target;
    addKeyboardSelector = action;
}

- (void)addKeyboard:(UITextField *)textField
{
    SuppressPerformSelectorLeakWarning([addKeyboardTarget performSelector:addKeyboardSelector withObject:textField];);
}

- (void)setConstraintsWithView:(UIView *)superView
{
//    [self mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.mas_equalTo(0);
//        make.left.mas_equalTo(0);
//        make.right.mas_equalTo(0);
//    }];
    
    self.frame = CGRectMake(0, 0, superView.frame.size.width, self.frame.size.height);
    self.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
}

@end
